﻿////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright file="AbstractModBackup.cs" company="SingularityShift.com">
// Copyright (c) 2010 SingularityShift.com. All rights reserved.
// </copyright>
// <author>Ben McClure</author>
// <email>ben@singularityshift.com</email>
// <date>11/19/2010</date>
// <summary>Implements the abstract modifier backup class</summary>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace GameLib.Backups
{
    using GameLib.Games;

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    /// <summary>   Abstract mod backup. </summary>
    ///
    /// <remarks>   Ben McClure, 11/19/2010. </remarks>
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    public abstract class AbstractModBackup : AbstractDataBackup, IModBackup, IBackup
    {
        #region Fields

        /// <summary> The mod </summary>
        private IMod _mod;

        #endregion Fields

        #region Properties

        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Gets or sets the mod. </summary>
        ///
        /// <value> The mod. </value>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public IMod Mod
        {
            get { return _mod; }
            protected set { _mod = value; }
        }

        #endregion Properties

        public override int Backup(IBackupWriter writer)
        {
            writer.Write(this);
            return writer.Count;
        }

        public override int Restore(IBackupReader reader)
        {
            IModBackup restored = (IModBackup)reader.Read(this);
            Mod = restored.Mod;
            Created = restored.Created;
            return reader.Count;
        }
    }
}